Skip to content

Fix library search matching interface control text#47

Open
HMAKT99 wants to merge 2 commits into
Forward-Future:mainfrom
HMAKT99:fix/search-excludes-control-text
Open

Fix library search matching interface control text#47
HMAKT99 wants to merge 2 commits into
Forward-Future:mainfrom
HMAKT99:fix/search-excludes-control-text

Conversation

@HMAKT99

@HMAKT99 HMAKT99 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The homepage library search matched interface control text, so several common words filtered nothing.

updateLibrary() built each row's search haystack from the entire row's textContent:

const searchableText = `${row.dataset.search} ${row.textContent}`;

A loop row's textContent includes the "Copy loop" action button, and — after script.js runs — the injected "Show more" / "Show less" prompt toggle. Because every row contains those strings, typing copy, show, more, or less matched all loops instead of filtering them.

Fix

Snapshot each row's searchable text once at load, reading the .cell-loop content (category, attribution, title, summary, and prompt) before the prompt toggle button is inserted. The cached, pre-normalized value is then reused on every keystroke.

This:

  • excludes the .cell-action "Copy loop" button and the injected toggle from the search index,
  • keeps title / summary / prompt / data-search keyword matching fully intact, and
  • avoids re-reading textContent for all rows on every keystroke.

Verification

  • Before: search copy or show → all 44 loops shown. After: those words match only loops whose content actually contains them.
  • node scripts/check.mjsLoop Library checks passed.
  • node --check site/script.js
  • node scripts/build-skill-catalog.mjs && node scripts/build-loop-pages.mjs && node scripts/build-social-images.mjs → no artifact drift (git status clean apart from site/script.js).
  • npm --prefix worker run check → tests pass.

The homepage search built its per-row haystack from the entire row's
textContent, which includes the "Copy loop" action button and the
JavaScript-injected "Show more"/"Show less" prompt toggle. As a result,
typing copy, show, more, or less matched every loop instead of filtering.

Snapshot each row's searchable text once at load from the .cell-loop
content (category, attribution, title, summary, and prompt) before the
toggle button is inserted, and reuse that cached value when filtering.
This keeps title/prompt/keyword search intact while excluding interface
controls, and avoids re-reading textContent on every keystroke.
@HMAKT99

HMAKT99 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for building Loop Library — the agent-native framing and the care in the catalog really show.

This one's a small, self-contained fix. The homepage search built its haystack from each row's full textContent, which now includes the "Copy loop" button and the JS-injected "Show more"/"Show less" toggle — so typing copy, show, more, or less matched every loop. Easy to see before/after: search copy on the live site today and all 44 loops stay. The fix snapshots the .cell-loop text once at load (so it also avoids re-reading textContent on every keystroke) and keeps title/prompt/keyword search intact.

I followed AGENTS.md — node scripts/check.mjs, all three builders, and the worker tests pass locally with no artifact drift. Happy to tweak naming or approach to match your conventions.

@mberman84 mberman84 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search-indexing change itself is correct and passed the integrated checks/browser verification. One deployment blocker remains: this changes site/script.js without changing the versioned script URL currently referenced as ?v=20260620-newest-first.

The live asset is cacheable for an hour with stale-while-revalidate, so existing visitors can continue receiving the old search behavior after deployment. Please bump the shared script asset version everywhere it is emitted and validated, including the generated loop-page template and scripts/check.mjs, then regenerate affected pages.

Per review: site/script.js changed without bumping the versioned asset URL
(?v=20260620-primary-nav), so visitors holding the hour-cacheable,
stale-while-revalidate asset could keep running the old search behavior.
Bump the shared script.js version to 20260621-search-index across the
homepage, Learn and Agents pages, the loop-page generator, and the
scripts/check.mjs assertions, then regenerate the loop detail pages.
@HMAKT99

HMAKT99 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — good catch on the cache angle. Bumped the shared script.js version to 20260621-search-index across the homepage, Learn/Agents pages, the loop-page generator, and the scripts/check.mjs assertions, then regenerated the loop detail pages. node scripts/check.mjs + all three builders are green with no drift.

@HMAKT99

HMAKT99 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@mberman84 this is ready for another look whenever you have a moment — the asset version is bumped and the loop pages regenerated. Thanks for the careful review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants